package cn.xiaobai.j2exe.utils;

import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;

/**
 * 对话框工具
 *
 * @Author yangdaji
 * @Date 2024/1/2
 * @PackageName cn.xiaobai.j2exe.utils
 * @ClassName DialogUtils
 */
public class DialogUtils {

    private static final Alert alert = new Alert(Alert.AlertType.NONE);

    static {
        String style = """
                 -fx-background-color: #A8A8AE;
                 -fx-text-fill: #2c313c;
                 -fx-font-size: 10pt;
                 -fx-border-radius: 5px;
                 
                 -fx-border-color: #3a4049;
                 -fx-border-width: 1px;
                 -fx-border-style: solid;
                """;
        alert.getDialogPane().setStyle(style);
        alert.getButtonTypes().add(ButtonType.OK);
    }

    /**
     * 弹出提示
     *
     * @param title   标题
     * @param content 内容
     */
    public static void popUp(String title, String content) {
        alert.setContentText(content);
        alert.setTitle(title);
        alert.showAndWait()
                .filter(state -> state == ButtonType.OK);
    }
}
